<?php
declare(strict_types=1);
namespace App\Service\Topic\Topic;
use App\Models\Topic\Topic;
class TopicShow implements TopicInterface{

    public function index($request,$topic):object{
        return $topic->withOrder($request->order)
            ->with('user', 'category')
            ->where('status',Topic::StatusSuccess)
            ->paginate(20);
    }
    public function categories_show($category_id,$request_order,$topic):object{
        return $topic->withOrder($request_order)
            ->where('category_id', $category_id)
            ->with('user', 'category')   // 预加载防止 N+1 问题
            ->where('status',Topic::StatusSuccess)
            ->paginate(20);
    }
}
